package com.example.demo.trade.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.trade.model.TradeOrder;
import com.example.demo.trade.service.TradeOrderService;

@RestController
@RefreshScope
@RequestMapping("/trade")
public class TradeController {

    @Value("${web.name}")
    public String             name;
    @Autowired
    private TradeOrderService tradeOrderService;

    @RequestMapping("/test")
    public String test() {
        tradeOrderService.test();
        return "[trade] test";
    }

    @RequestMapping("/order/list")
    public String list() {
        List<TradeOrder> list = tradeOrderService.list();
        return list.toString();
    }

    @RequestMapping("/order/save")
    public void orderSave(@RequestBody TradeOrder order) {
        tradeOrderService.save1(order);
    }

}
